﻿' <summary>
' BeeWit IDE Entorno de desarrollo Visual para php.
' BeeWitPHP IDE es el único entorno de desarrollo para PHP 
' de tipo WYSIWYG (What You See Is What You Get). 
' ¡Ahora si!, aproveche la potencia del lenguaje PHP 
' y desarrolle más rápidamente gracias a la programación 
' intuitiva de BeeWit.
' Copyright © 2010 Dewins Murillo Garcia 
' EMAIL: dewinsmg@gmail.com
' EMAIL: dewins@beewitsoft.com
' Este Programa es Software Libre: usted puede redistribuirlo 
' y/o modificarlo bajo los términos de la Licencia Publica General 
' GNU como es publicada por la Fundacion de Software Libre; 
' en la 3ra versión de la licencia.
' Este programa es distribuido con la esperanza de que sea útil, 
' pero SIN GARANTÍA ALGUNA; sin siquiera la garantía implícita 
' de VALOR COMERCIAL o FORMADO PARA UN PROPÓSITO EN PARTICULAR. 
' Vea la Licencia Publica General GNU para mas detalles.
' Usted debe haber recibido una copia de la Licencia Publica General 
' GNU junto con este programa. Si no, vaya a http://www.beewitsoft.com
' o en http://code.google.com/p/ajax-beewit-php-ide/
' </summary>
' <remarks></remarks>

Public Class ctlControls

    Public LastControlSelected As String = ""

    Private Sub ctlControls_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.tbControls.Items.Clear()
        Me.ToolStrip1.ImageList = Object_Icons.bmpImageList
        Me.btnRefresh.ImageKey = "icon_refresh"
        Me.btnRefresh.ToolTipText = Object_Language.Lang_Text("Refresh")
    End Sub

    Public Sub LoadControls()
        Dim Directory As String = ""
        lstControls.Items.Clear()
        Me.tbControls.Items.Clear()

        Dim NodeClasses() As clsNode = Control_Explorer.SearchClasses

        If Not NodeClasses Is Nothing Then
            For Each ClassNode As clsNode In NodeClasses
                If ClassNode.Extention.ToString.ToUpper = "CJX" Then
                    Dim ClassName As String = Object_Expression.GetClassName(ClassNode.ContentCode)
                    Dim Directories() As String = ClassNode.Path.ToString.Split("\")

                    If Directory <> Directories(Directories.Length - 2).ToString Then
                        Directory = Directories(Directories.Length - 2).ToString
                        Dim ElementGroup As New ToolStripLabel(Directory)
                        ElementGroup.Text = Directory
                        ElementGroup.AutoSize = False
                        ElementGroup.Tag = Directory
                        ElementGroup.ToolTipText = Directory
                        ElementGroup.Width = 12000
                        ElementGroup.TextAlign = ContentAlignment.MiddleLeft
                        ElementGroup.ForeColor = Color.White
                        ElementGroup.Height = 16
                        ElementGroup.BackgroundImage = Object_Icons.bmpImage("image_background_group")
                        ElementGroup.AllowDrop = True
                        Me.tbControls.Items.Add(ElementGroup)
                    End If
                    Dim Element As New ToolStripButton(ClassName)

                    Element.AllowDrop = True
                    Me.tbControls.DoDragDrop(Element, DragDropEffects.Copy Or DragDropEffects.Move)
                    Element.AutoSize = False
                    Element.Tag = ClassNode.Path.ToString
                    Element.ToolTipText = ClassNode.Path.ToString
                    Element.ImageAlign = ContentAlignment.MiddleLeft
                    Element.TextImageRelation = TextImageRelation.ImageBeforeText
                    Element.Width = 12000
                    Element.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
                    Element.ImageScaling = ToolStripItemImageScaling.None
                    Element.TextAlign = ContentAlignment.MiddleCenter
                    AddHandler Element.MouseDown, AddressOf ItemMouseDown
                    AddHandler Element.MouseUp, AddressOf ItemMouseUp
                    'AddHandler Element.MouseMove, AddressOf ItemMouseMove
                    'AddHandler Element.DragDrop, AddressOf ItemDragDrop
                    'AddHandler Element.DragEnter, AddressOf ItemDragEnter
                    'AddHandler Element.DragLeave, AddressOf ItemDragLeave
                    'AddHandler Element.DragOver, AddressOf ItemDragOver

                    Try
                        Element.Image = Object_Icons.bmpImageFromFile(ClassNode.Path.ToString & ".gif")
                    Catch ex As Exception
                        Element.Image = Object_Icons.bmpImage("icon_cjx")
                    End Try
                    Me.tbControls.Items.Add(Element)
                End If
            Next
        End If
    End Sub

    Private Sub ItemMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        General.DragingControl = True
        Me.LastControlSelected = sender.text
        sender.DoDragDrop("", DragDropEffects.Copy)
    End Sub

    Private Sub ItemMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        Control_Console.AddMessages("ItemMouseUp - " & Now(), ctlConsole.enumTypeMessages.isINFORMATION)
    End Sub

    Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
        LoadControls()
    End Sub


End Class
